package com.jiamao.goplay.ui.login.vm;

import android.app.Application;
import android.os.Bundle;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.jiamao.goplay.data.DataRepository;
import com.jiamao.goplay.ui.login.AddHeadImageFragment;
import com.tamsiree.rxkit.view.RxToast;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;
import me.goldze.mvvmhabit.bus.event.SingleLiveEvent;

public class RegisterAddBasicInfoModel extends BaseViewModel<DataRepository> {

    //昵称
    public ObservableField<String> nickName = new ObservableField<>("");
    //出生年月日
    public ObservableField<String> birthday = new ObservableField<>("");
    //对应星座
    public ObservableField<String> constellation = new ObservableField<>("");
    public ObservableField<String> constellations = new ObservableField<>("");
    //性别
    public ObservableField<String> sex = new ObservableField<>("");

    public RegisterAddBasicInfoModel(@NonNull Application application, DataRepository dataRepository) {
        super(application, dataRepository);
    }
    public UIChangeObservable uc = new UIChangeObservable();
    public class UIChangeObservable {
        //密码开关观察者
        public SingleLiveEvent<Boolean> showTime = new SingleLiveEvent<>();

        public SingleLiveEvent<Boolean> showSex = new SingleLiveEvent<>();
    }

    //下一步按钮点击时间
    public BindingCommand nextButtonOnclickCommand = new BindingCommand(new BindingAction() {
        @Override
        public void call() {

            if (TextUtils.isEmpty(nickName.get()) || TextUtils.isEmpty(birthday.get()) ||
                    TextUtils.isEmpty(constellations.get()) || TextUtils.isEmpty(sex.get())
             ){
                RxToast.showToastShort("请输入完整参数");
                return;
            }
            Bundle bundle = new Bundle();
            bundle.putString("nickName",nickName.get());
            bundle.putString("birthday",birthday.get());
            bundle.putString("constellations",constellations.get());
            bundle.putString("sex",sex.get());
            startContainerActivity(AddHeadImageFragment.class.getCanonicalName(),bundle);
            finish();
        }
    });

    //下一步按钮点击时间
    public BindingCommand sexButtonOnclickCommand = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
                uc.showSex.setValue(false);
        }
    });

    //下一步按钮点击时间
    public BindingCommand ageButtonOnclickCommand = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            uc.showTime.setValue(false);
        }
    });




}
